var module_id, module_name, module_category2, module_category, module_type2
//字典。
function __dic(val1, val2) {
    if (val1 == "content") {
        if (val2 == "1") {
            return "m1a";
        } else if (val2 == "2") {
            return "m1b";
        } else if (val2 == "3") {
            return "m1c";
        } else if (val2 == "4") {
            return "m1d";
        } else if (val2 == "5") {
            return "m1e";
        } else if (val2 == "6") {
            return "m1f";
        }
    } else if (val1 == "highstock") {
        if (val2 == "1") {
            return "img3/menua";
        } else if (val2 == "2") {
            return "img3/menub";
        } else if (val2 == "3") {
            return "img3/menuc";
        } else if (val2 == "4") {
            return "img3/menud";
        }
    } else if (val1 == "highstock_combine") {
        if (val2 == "") {
            return "img3/bj";
        } else if (val2 == "n") {
            return "img3/nh";
        }
    }
}
function __init() {
    __date_select(5);
    $.datepicker.regional['zh-CN'] = {
        clearText: '清除',
        clearStatus: '清除已选日期',
        closeText: '关闭',
        closeStatus: '不改变当前选择',
        prevText: '<上月',
        prevStatus: '显示上月',
        prevBigText: '<<',
        prevBigStatus: '显示上一年',
        nextText: '下月>',
        nextStatus: '显示下月',
        nextBigText: '>>',
        nextBigStatus: '显示下一年',
        currentText: '今天',
        currentStatus: '显示本月',
        monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        monthStatus: '选择月份',
        yearStatus: '选择年份',
        weekHeader: '周',
        weekStatus: '年内周次',
        dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
        dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
        dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
        dayStatus: '设置 DD 为一周起始',
        dateStatus: '选择 m月 d日, DD',
        dateFormat: 'yy-mm-dd',
        firstDay: 1,
        initStatus: '请选择日期',
        isRTL: false
    };
    $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
    $.datepicker.setDefaults({
        dateFormat: 'yy-mm-dd',
        changeMonth: true,
        changeYear: true
    });
    $("#_date_select_startdate").datepicker();
    $("#_date_select_enddate").datepicker();
}
var const_stock = 2;
function __select_highstock(val1) {
    if (const_stock != val1) {
        $("#Image" + const_stock).attr("src", __dic("highstock", const_stock) + "1.jpg");
        $("#Image" + val1).attr("src", __dic("highstock", val1) + "2.jpg");
        if (val1 == 4) {
            $("#_date_select_mask").show();
        } else {
            $("#_date_select_mask").hide();
        }
        eval("__get_highStock" + val1 + "A();");
        const_stock = val1;
    }
}
var const_date_select = 0;
function __date_select(val1) {
    if (const_date_select != val1 || val1 == 0) {
        const_date_select = val1;
        if (val1 == 0) {
            if ($("#_date_select_startdate").val() == '' || $("#_date_select_enddate").val() == '') {
                __date_select(5);
            } else {
                $("#_date_select0").css("background-image", "url(img3/33032.jpg)");
                for (i = 1; i <= 5; i++) {
                    if (i < 5) {
                        $("#_date_select" + i).removeClass("mxta mxtb mxtc mxtd").addClass("mxtc");
                    } else {
                        $("#_date_select" + i).removeClass("mxta mxtb mxtc mxtd").addClass("mxtd");
                    }
                }
            }
        } else {
            $("#_date_select0").css("background-image", "");
            for (i = 1; i <= 5; i++) {
                if (i == val1) {
                    $("#_date_select" + i).removeClass("mxta mxtb mxtc mxtd").addClass("mxta");
                } else if (i < val1) {
                    $("#_date_select" + i).removeClass("mxta mxtb mxtc mxtd").addClass("mxtc");
                } else if (i > val1) {
                    $("#_date_select" + i).removeClass("mxta mxtb mxtc mxtd").addClass("mxtb");
                }
            }
            $("#_date_select_startdate").val('');
            $("#_date_select_enddate").val('');
        }
        eval("__get_highStock" + const_stock + "A();");
    }
}
//六个详细内容切换。
var const_content = 1;
function __select_content(val1) {
    if (const_content != val1) {
        $("#_content" + const_content).switchClass(__dic("content", const_content) + "2", __dic("content", const_content) + "1");
        $("#_content" + val1).switchClass(__dic("content", val1) + "1", __dic("content", val1) + "2");
        const_content = val1;
    }
    $("#_module_content" + val1).show();
    for (i = 1; i <= 6; i++) {
        if (i != val1) {
            $("#_module_content" + i).hide();
        }
    }
}
//四个价格切换。
var const_price = 0;
function __select_price(val1, val2) {
    if (const_price != val1) {
        $("#_price" + const_price).removeClass("ju");
        $("#_price" + val1).addClass("ju");
        $("#_price").html(val2 + "元");
        const_price = val1;
        if (val1 == 1) {
            $("#_price_postfix").html("/月");
        } else {
            $("#_price_postfix").html("/" + val1 + "个月");
        }
    }
}
var const_price_vip = 0;
function __select_price_vip(val1, val2) {
    if (const_price_vip != val1) {
        $("#_price" + const_price_vip + "_vip").removeClass("ju");
        $("#_price" + val1 + "_vip").addClass("ju");
        $("#_price_vip").html(val2 + "元");
        const_price_vip = val1;
        if (val1 == 1) {
            $("#_price_vip_postfix").html("/月");
        } else {
            $("#_price_vip_postfix").html("/" + val1 + "个月");
        }
    }
}
function __module_content1_list(val1, val2) {
    $.get("/xml/module_content1?id=" + module_id + "&sDate=" + val1 + "&nav=" + val2 + "&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            var r1 = getNodeValue(xml, 'r1');
            if (r == "") {
                $("#_module_content1_main").html(r1);
                $('#_module_content1_box a').lightBox();
                __module_content1_start();
            } else {
                alert(r);
            }
        }, "xml");
}
function __module_content2_list() {
    $.get("/xml/module_content?id=" + module_id + "&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            $("#_module_content2_main").html(r);
        }, "xml");
}
function __module_content3_list(val1, val2) {
    $.get("/xml/module_content?id=" + module_id + "&page=" + val2 + "&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            $("#_module_content3_main").html(r);
        }, "xml");
}
function __module_content4_list() {
    $.get("/xml/module_content?id=" + module_id + "&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            $("#_module_content4_main").html(r);
            $('#_module_content4_box a').lightBox();
            __module_content4_start();
        }, "xml");
}
function __module_content5_list(val1, val2) {
    $.get("/xml/module_content?id=" + module_id + "&page=" + val2 + "&s=" + escape(val1) + "&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            $("#_module_content5_main").html(r);
        }, "xml");
}
function __shouxufei() {
    eval("__get_highStock" + const_stock + "A();");
}
function __shouxufei_check() {
    if ($.isNumeric($('#_shouxufei_text').val()) == false) {
        $('#_shouxufei_text').val("0");
    } else if ($('#_shouxufei_text').val() > 1000) {
        $('#_shouxufei_text').val("1000");
    }
}
function __module_buy(val1, val2, val3, val4) {
    window.location.href = "my_cart?id=" + val1 + "&qty=" + val2 + "&qty_vip=" + val3 + "&t=" + val4;
}
//K线图
function __get_highStock1A() {
    $("#_module_title").html(module_category2 + '连续合约日K线');
    $("#_load").show();
    $("#container").hide();
    $.get('/xml/data_module1A?v=' + const_date_select + '&v1=' + $("#_date_select_startdate").val() + '&v2=' + $("#_date_select_enddate").val() + '&v3=' + module_category + '&' + Math.random(), {}, function (xml) {
        var r = getNodeValue(xml, 'r');
        var r1 = getNodeValue(xml, 'r1');
        var r2 = getNodeValue(xml, 'r2');
        $("#_date_select_startdate").val(r1);
        $("#_date_select_enddate").val(r2);
        // create the chart
        chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container',
                events: {
                    load: function () {
                        $("#_load").hide();
                        $("#container").show();
                    }
                }
            },
            credits: {
                text: '中量网版权所有',
                href: 'http://www.ChinaLHTZ.com',
                position: {
                    align: 'right',
                    x: -10,
                    verticalAlign: 'bottom',
                    y: -3
                },
                style: {
                    cursor: 'pointer',
                    color: '#666',
                    fontSize: '12px',
                    fontFamily: 'Microsoft YaHei'
                }
            },
            exporting: {
                enabled: false
            },
            rangeSelector: {
                enabled: false
            },
            scrollbar: {
                enabled: false
            },
            navigator: {
                enabled: false
            },
            xAxis: {
                type: 'datetime',
                dateTimeLabelFormats: {
                    second: '%Y-%m-%d<br/>%H:%M:%S',
                    minute: '%Y-%m-%d<br/>%H:%M',
                    hour: '%Y-%m-%d<br/>%H:%M',
                    day: '%Y<br>%m-%d',
                    week: '%Y<br>%m-%d',
                    month: '%Y-%m',
                    year: '%Y'
                }
            },
            yAxis: {
                labels: {
                    enabled: true
                }
            },
            tooltip: {
                xDateFormat: '%Y年%m月%d日'
            },
            navigator: {
                enabled: false
            },
            scrollbar: {
                enabled: false
            },
            series: [{
                type: 'candlestick',
                name: module_category2,
                data: eval(r),
                dataGrouping: {
                    enabled: false
                },
                animation: {
                    duration: 2000
                }
            }]
        });
    }, "xml");
}
//资金盈收曲线
function __get_highStock2A() {
    $("#_module_title").html("资金盈收曲线图");
    $("#_load").show();
    $("#container").hide();
    $.get('/data_module?id=' + GetQueryString("id") + '&v=' + const_date_select + '&v1=' + $("#_date_select_startdate").val() + '&v2=' + $("#_date_select_enddate").val() + '&v3=' + $('#_shouxufei_text').val() + '&' + Math.random(), {}, function (xml) {
            var r = getNodeValue(xml, 'r');
            var r1 = getNodeValue(xml, 'r1');
            var r2 = getNodeValue(xml, 'r2');
            $("#_date_select_startdate").val(r1);
            $("#_date_select_enddate").val(r2);
            Highcharts.setOptions({
                global: {
                    useUTC: false
                }
            });
            $('#highcharts-0').highcharts({
                chart: {
                    events: {
                        load: function () {
                            $("#container").show();
                            $("#_load").hide();
                        }
                    }
                },
                credits: {
                    text: '共喜财富版权所有',
                    href: 'http://www.ChinaLHTZ.com',
                    position: {
                        align: 'right',
                        x: -10,
                        verticalAlign: 'bottom',
                        y: -3
                    },
                    style: {
                        cursor: 'pointer',
                        color: '#666',
                        fontSize: '12px',
                        fontFamily: 'Microsoft YaHei'
                    }
                },
                xAxis: {
                    type: 'datetime',
                    labels: {
                        formatter: function () {
                            return Highcharts.dateFormat('%Y-%m-%d', this.value);
                        }
                    }
                },
                yAxis: {
                    labels: {
                        formatter: function () {
                            return currencyFormatter(this.value, '.', 3, ',') + ' 元';
                        }
                    }
                }
                ,
                tooltip: {
                    shared: true
                }
                ,
                series: [{
                    name: '累计净利',
                    type: 'areaspline',//'areaspline',
                    pointInterval: 7 * 24 * 3600 * 1000,// 间隔一周
                    pointStart: Date.UTC(2013, 0, 01),
                    data:eval(r),
                    animation: {
                        duration: 2000
                    }
                }]
            });
        }, "xml");
}
//柱状图
function __get_highStock3A() {
    $("#_module_title").html("月度盈收柱状图");
    $("#_load").show();
    $("#container").hide();
    $.get('/xml/data_module3A.asp?id=' + module_id + '&v=' + const_date_select + '&v1=' + $("#_date_select_startdate").val() + '&v2=' + $("#_date_select_enddate").val() + '&v3=' + $('#_shouxufei_text').val() + '&' + Math.random(), {}, function (xml) {
        var r = getNodeValue(xml, 'r');
        var r1 = getNodeValue(xml, 'r1');
        var r2 = getNodeValue(xml, 'r2');
        $("#_date_select_startdate").val(r1);
        $("#_date_select_enddate").val(r2);
        window.chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container',
                events: {
                    load: function () {
                        $("#_load").hide();
                        $("#container").show();
                    }
                }
            },
            credits: {
                text: '中量网版权所有',
                href: 'http://www.ChinaLHTZ.com',
                position: {
                    align: 'right',
                    x: -10,
                    verticalAlign: 'bottom',
                    y: -3
                },
                style: {
                    cursor: 'pointer',
                    color: '#666',
                    fontSize: '12px',
                    fontFamily: 'Microsoft YaHei'
                }
            },
            exporting: {
                enabled: false
            },
            rangeSelector: {
                enabled: false
            },
            scrollbar: {
                enabled: false
            },
            navigator: {
                enabled: false
            },
            xAxis: {
                type: 'datetime',
                dateTimeLabelFormats: {
                    second: '',
                    minute: '%Y-%m-%d<br/>%H:%M',
                    hour: '%Y-%m',
                    day: '%Y-%m',
                    week: '%Y-%m',
                    month: '%Y-%m',
                    year: '%Y'
                }
            },
            yAxis: {
                labels: {
                    x: -10,
                    formatter: function () {
                        return currencyFormatter(this.value, '.', 3, ',') + ' 元';
                    }
                }
            },
            tooltip: {
                formatter: function () {
                    var s = '' + Highcharts.dateFormat('%Y年%m月', this.x) + '';
                    $.each(this.points, function (i, point) {
                        s += '<br/><b>当月盈利：' + currencyFormatter(point.y, '.', 3, ',') + ' 元</b>';
                    });
                    return s;
                }
            },
            series: [{
                name: '当月盈利',
                data: eval(r),
                type: 'column',//'areaspline',
                dataGrouping: {
                    forced: true,
                    units: [[
                        'month',
                        [1]
                    ]]
                }
            }]
        });
    }, "xml");
}
//多空头比较饼状图
function __get_highStock4A(val1) {
    $("#_module_title").html("多空头比较饼状图");
    $("#_load").show();
    $("#container").hide();
    $.get('/xml/data_module4A.asp?id=' + module_id + '&c=' + $('#_shouxufei_text').val() + '&' + Math.random(), {}, function (xml) {
        var r = getNodeValue(xml, 'r');
        var r1 = getNodeValue(xml, 'r1');
        var r2 = getNodeValue(xml, 'r2');
        var r3 = getNodeValue(xml, 'r3');
        var r4 = getNodeValue(xml, 'r4');
        var r5 = getNodeValue(xml, 'r5');
        var r6 = getNodeValue(xml, 'r6');
        window.chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                events: {
                    load: function () {
                        $("#container").show();
                        $("#_load").hide();
                    }
                },
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            credits: {
                text: '中量网版权所有',
                href: 'http://www.ChinaLHTZ.com',
                position: {
                    align: 'right',
                    x: -10,
                    verticalAlign: 'bottom',
                    y: -3
                },
                style: {
                    cursor: 'pointer',
                    color: '#666',
                    fontSize: '12px',
                    fontFamily: 'Microsoft YaHei'
                }
            },
            exporting: {
                enabled: false
            },
            title: {
                text: ''
            },
            tooltip: {
                formatter: function () {
                    var unit = {
                        'a': ' 元',
                        'a1': ' 次',
                        'a2': ' 次',
                        'a3': ' 次',
                        'a4': ' 元',
                        'a5': ' 元',
                        'a6': '%'
                    }[this.series.name];
                    if (this.series.name == 'a6') {
                        return '' +
                            this.point.name + '：<b>' + this.y + unit + '</b>';
                    } else {
                        return '' +
                            this.point.name + '：' + currencyFormatter(this.y, '.', 3, ',') + unit + '<br><b>' + Math.round(this.point.percentage * 100) / 100 + '%</b>';
                    }
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: 'white',
                        distance: -60
                    },
                    showInLegend: false,
                    shadow: {
                        color: '#666666',
                        offsetX: 10,
                        offsetY: 10,
                        width: 20
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'a',
                data: eval(r),
                center: [510, 210],
                size: 320
            }, {
                type: 'pie',
                name: 'a1',
                data: eval(r1),
                center: [100, 80],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }, {
                type: 'pie',
                name: 'a2',
                data: eval(r2),
                center: [100, 230],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }, {
                type: 'pie',
                name: 'a3',
                data: eval(r3),
                center: [100, 380],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }, {
                type: 'pie',
                name: 'a4',
                data: eval(r4),
                center: [230, 80],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }, {
                type: 'pie',
                name: 'a5',
                data: eval(r5),
                center: [230, 230],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }, {
                type: 'pie',
                name: 'a6',
                data: eval(r6),
                center: [230, 380],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: true,
                    color: 'white',
                    distance: -30,
                    rotation: 45
                }
            }]
        });
    }, "xml");
}
function __right_module_list2() {
    $.get("/xml/right_module2.asp?c=" + module_category + "&n=5&" + Math.random(),
        {},
        function (xml) {
            var r = getNodeValue(xml, 'r');
            $("#_right_module_list").html(r);
        }, "xml");
}